Skip to content

fix: catch panics from EC point creation (e.g. the point is at infinity)#4790

Merged
TomAFrench merged 5 commits intonoir-lang:masterfrom
just-mitch:better-error-logging-in-ec-addition
Apr 15, 2024
Merged

fix: catch panics from EC point creation (e.g. the point is at infinity)#4790
TomAFrench merged 5 commits intonoir-lang:masterfrom
just-mitch:better-error-logging-in-ec-addition

Conversation

@just-mitch
Copy link
Copy Markdown
Contributor

Description

Problem*

Presently noir programs panic when trying to add points not in the curve.

For example:

#[test]
fn test_addition_with_zero() {
    let a = pedersen_commitment([1]);
    let b = pedersen_commitment([0]); // returns the point at infinity
    let result = a + b; // panics

    let expected = pedersen_commitment([1]);
    assert(result == expected);
}

Summary*

Ideally we would check if one of the operands to the ec addition is the point at infinity and return the other operand if so. This at least prevents it from panicking and returns a nicer error.

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants